﻿using ELab.Serialization;
using ELab.Serialization.Data;
using System.Collections.Generic;

namespace ELab.Communication.Messages.ControllerMessages
{
    /// <summary>
    /// This message is sent from ELab server to ELab manager as a response to GetApplicationListMessage message.
    /// </summary>
    public class GetQuestionListResponseMessage : ControlMessage
    {
        /// <summary>
        /// Gets MessageTypeId for GetApplicationListResponseMessage.
        /// </summary>
        public override int MessageTypeId
        {
            get { return ControlMessageFactory.MessageTypeIdGetQuestionListResponseMessage; }
        }

        /// <summary>
        /// List of client applications.
        /// </summary>
        public Question[] Questions { get; set; }

        /// <summary>
        /// Serializes this message.
        /// </summary>
        /// <param name="serializer">Serializer used to serialize objects</param>
        public override void Serialize(IELabSerializer serializer)
        {
            base.Serialize(serializer);
            serializer.WriteObjectArray(Questions);
        }

        /// <summary>
        /// Deserializes this message.
        /// </summary>
        /// <param name="deserializer">Deserializer used to deserialize objects</param>
        public override void Deserialize(IELabDeserializer deserializer)
        {
            base.Deserialize(deserializer);
            Questions = deserializer.ReadObjectArray(() => new Question());
        }

    }
}
